package cn.b.sky.common.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegExUtil {

  /** 
   * @Fields CODE_EX : 常用编码
   */
  public static final String CODE_EX = "^[0-9a-zA-Z]{1,40}$";

  /** 
   * @Fields NUMBERIC_EX : 数字
   */
  public static final String NUMBERIC_EX = "^d*$";

  /** 
   * @Fields INT_EX : 整数
   */
  public static final String INT_EX = "^-?[1-9]d*$";

  /** 
   * @Fields FLOAT_EX : 浮点数
   */
  public static final String FLOAT_EX = "^-?([1-9]d*.d*|0.d*[1-9]d*|0?.0+|0)$";
  
  private RegExUtil() {
    // Hide the constructor
  }

  public static boolean matches(String s, String ex) {
    Pattern pat = Pattern.compile(ex);
    Matcher mat = pat.matcher(s);
    return mat.matches();
  }

}
